<template>
	<div class="app">
		<h1>我是App组件</h1>
		<h3>Child1给我的电脑：{{computer}}</h3>
		<h3>Child2给我的手机：{{phone}}</h3>
		<h3>孙子给我的玩具：{{toy}}</h3>
		<Child1 @get-computer="saveComputer"/>
		<br>
		<Child2 :savePhone="savePhone" @get-toy="saveToy"/>
	</div>
</template>

<script>
	import Child1 from './components/Child1.vue'
	import Child2 from './components/Child2.vue'

	export default {
		name:'App',
		components:{Child1,Child2},
		data() {
			return {
				computer:'',
				phone:'',
				toy:''
			}
		},
		methods:{
			saveComputer(value){
				// console.log('App',value)
				this.computer = value
			},
			savePhone(value){
				this.phone = value
			},
			saveToy(value){
				this.toy = value
			}
		}
	}
</script>

<style>
	.app{
		background-color: gray;
		padding: 20px;
	}
</style>